package com.z.system.model;

import java.util.Date;
import java.util.UUID;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

/**
 * 日志实体类，对应数据库中的t_logs表
 * 用于记录接口请求参数、错误日志、模块、接口、功能等辅助日志筛查的字段
 */
@Entity
@Table(name = "t_logs")
public class Log {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(columnDefinition = "UUID")
    private UUID id;

    // 操作用户ID
    @Column(name = "user_id", columnDefinition = "UUID")
    private UUID userId;

    // 操作用户名
    @Column(name = "username", length = 255)
    private String username;

    // 操作模块
    @Column(name = "module", length = 255)
    private String module;

    // 操作接口
    @Column(name = "api_path", length = 255)
    private String apiPath;

    // 请求方法
    @Column(name = "request_method", length = 10)
    private String requestMethod;

    // 操作功能描述
    @Column(name = "operation", length = 255)
    private String operation;

    // 请求参数
    @Column(name = "request_params", columnDefinition = "text")
    private String requestParams;

    // 响应状态码
    @Column(name = "status_code")
    private Integer statusCode;

    // 响应消息
    @Column(name = "response_msg", columnDefinition = "text")
    private String responseMsg;

    // 错误信息
    @Column(name = "error_msg", columnDefinition = "text")
    private String errorMsg;

    // 请求IP
    @Column(name = "request_ip", length = 50)
    private String requestIp;

    // 操作时间
    @Column(name = "create_time")
    private Date createTime;

    // 请求耗时(毫秒)
    @Column(name = "execute_time")
    private Long executeTime;

    // 设备信息 - 使用text类型以支持较长的User-Agent字符串
    @Column(name = "user_agent", columnDefinition = "text")
    private String userAgent;
    
    // 服务器IP
    @Column(name = "server_ip", length = 50)
    private String serverIp;

    // Getters and Setters
    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }

    public UUID getUserId() {
        return userId;
    }

    public void setUserId(UUID userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getModule() {
        return module;
    }

    public void setModule(String module) {
        this.module = module;
    }

    public String getApiPath() {
        return apiPath;
    }

    public void setApiPath(String apiPath) {
        this.apiPath = apiPath;
    }

    public String getRequestMethod() {
        return requestMethod;
    }

    public void setRequestMethod(String requestMethod) {
        this.requestMethod = requestMethod;
    }

    public String getOperation() {
        return operation;
    }

    public void setOperation(String operation) {
        this.operation = operation;
    }

    public String getRequestParams() {
        return requestParams;
    }

    public void setRequestParams(String requestParams) {
        this.requestParams = requestParams;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    public String getResponseMsg() {
        return responseMsg;
    }

    public void setResponseMsg(String responseMsg) {
        this.responseMsg = responseMsg;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public String getRequestIp() {
        return requestIp;
    }

    public void setRequestIp(String requestIp) {
        this.requestIp = requestIp;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Long getExecuteTime() {
        return executeTime;
    }

    public void setExecuteTime(Long executeTime) {
        this.executeTime = executeTime;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getServerIp() {
        return serverIp;
    }

    public void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }
}